﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using PhoneApplicPersons.Classes;

namespace PhoneApplicPersons
{
    public partial class MainPage : PhoneApplicationPage
    {
        
        // Конструктор
        public MainPage()
        {
            InitializeComponent();
            //(Application.Current as App).list = new ListOfPersons(new DS.DS_MOCK());
            (Application.Current as App).list = new ListOfPersons(new DS.DS_NET_CLIENT());
            (Application.Current as App).persona = null;
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            (Application.Current as App).list.Create(new Persona(1, "ssrd", "sf", 3));
            //(Application.Current as App).list.Create(new Persona(2, "ssrhngbd", "12sf", 4));
            //(Application.Current as App).list.Create(new Persona(3, "ssasedrd", "s56f", 5));
            SP_View.Children.Clear();
            foreach (Persona per in (Application.Current as App).list)
            {
                DrawPerson dp = new DrawPerson(per);
                SP_View.Children.Add(dp);
                dp.Draw();
            }
        }

        private void Btn_Add_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
        {
            (Application.Current as App).persona = null;
            this.NavigationService.Navigate(new Uri("/PAddPerson.xaml", UriKind.Relative));
            e.Complete();
            e.Handled = true;
        }
    }
}